<?php

namespace App\Transformers\Sms;

use App\Models\SmsRecord;
use League\Fractal\TransformerAbstract;

class SmsRecordsTransformer extends TransformerAbstract
{
    public function transform(SmsRecord $data)
    {
        return [
            'id'=>$data->id,
            'platform_account'=>$data->platform_account ?? '',
            'user_id'=>$data->user_id ?? '',
            'phone'=>$data->phone ?? '',
            'content'=>$data->content ?? '',
            'add_ip'=>$data->add_ip ?? '',
            'template_id'=>$data->template_id ?? '',
            'resultcode'=>$data->resultcode ?? '',
            'resultcode_type'=>$data->resultCodeEnum[$data->resultcode] ?? '',
            'created_at' => $data->created_at ? $data->created_at->format("Y-m-d H:i:s") : '',
            'updated_at' => $data->updated_at ? $data->updated_at->format("Y-m-d H:i:s") : '',
        ];
    }
}
